<?php 
$orders = $mvc->getObject(BargainsService::BARGAINS);
$categories = $mvc->getObject(CategoryService::CATEGORY);
$subcategories = $mvc->getObject(SubCategoryService::SUBCATEGORY);
$subcategories_new = $mvc->getObject(SubCategoryService::SUBCATEGORY . "2");
$regions = $mvc->getObject(RegionService::REGIONS);
$countries = $mvc->getObject(CountryService::COUNTRY);
$count = $mvc->getObject("count");
$pages = $mvc->getObject("pages");
?>
<div class="wrapLSearch">
	<div class="greyBox">
		<div class="viewBox viewBoxA">
			<div class="cT"><em class="cL"></em><em class="cR"></em></div>
			<div class="cL">
				<div class="cR">
					<div class="bodyBox">
						<h2>_i18n{Find bargain}</h2>
						<form action="view-bargains.html" method="get" id="search">
							<div class="unitBSearch">
								<p>
									<input name="order_name" class="inpTxt" type="text"  value="<? if(isset($_GET['order_name'])) echo $_GET['order_name']; ?>"/>
									<button name="search" type="submit"><span><strong>Search</strong></span></button>
								</p>
								<p class="itemFilter">
									<span class="item1FilterOpen"><a href="#" title="Advanced search">Advanced search</a></span>
								</p>
								<div class="unitFilter">
									<dl>
										<dt>_i18n{Industry}:</dt>
										<dd>
											<label>_i18n{Category}</label>
											<select name="category_id" class="gCategory">
												<option value="all">all</option>
							<?php			if (isset($categories) && $categories!=NULL){ 
					foreach($categories as $key=>$category){ ?>
													<option <?php echo isset($_GET['category_id'])&&$category[CategoryService::ID]==$_GET['category_id'] ? "selected='selected'" : NULL ; ?> value="<?php echo $category[CategoryService::ID] ?>"><?php echo $category[CategoryService::CAT_NAME] ?></option>
							<?php 				} 
				} ?>
											</select>
											<label>_i18n{SubCategory}</label>
											<select name="subcategory_id" class="gSubCategory">
												<option value="all">all</option>
							<?php			if (isset($subcategories) && $subcategories!=NULL){ 
					foreach($subcategories as $key=>$subcategory){ ?>						
													<option <?php echo isset($_GET['subcategory_id'])&&$subcategory[SubCategoryService::ID]==$_GET['subcategory_id'] ? "selected='selected'" : NULL ; ?> value="<?php echo $subcategory[SubCategoryService::ID] ?>"><?php echo $subcategory[SubCategoryService::SUBCAT_NAME] ?></option>
							<?php 				} 
				} ?>
											</select>
										</dd>
									</dl>
									<dl>
										<dt>_i18n{Location}:</dt>
										<dd>
											<label>_i18n{Country}</label>
											<select name="country_id">
												<option value="all">all</option>
							<?php			if (isset($countries) && $countries!=NULL){ 
					foreach($countries as $key=>$country){ ?>						
													<option <?php echo isset($_GET['country'])&&$country[CountryService::ID]==$_GET['country'] ? "selected='selected'" : NULL ; ?> value="<?php echo $country[CountryService::ID] ?>"><?php echo $country[CountryService::COUNTRY_NAME] ?></option>
							<?php 				} 
				} ?>
											</select>
											<label>_i18n{Region}</label>
											<select name="region_id">
												<option value="all">all</option>
							<?php			if (isset($regions) && $regions!=NULL){ 
					foreach($regions as $key=>$region){ ?>
													<option <?php echo isset($_GET['region'])&&$region[RegionService::ID]==$_GET['region'] ? "selected='selected'" : NULL ; ?> value="<?php echo $region[RegionService::ID] ?>"><?php echo $region[RegionService::REGION_NAME] ?></option>
							<?php 				} 
				} ?>
											</select>
										</dd>
									</dl>
									<dl>
										<dt>_i18n{Price}:</dt>
										<dd>
											<label> _i18n{from}</label>
											<input class="inpTxt" name="price_from" type="text" value="<? if(isset($_GET['price_from'])) echo $_GET['price_from']; ?>"/>
											<label>_i18n{to}</label>
											<input class="inpTxt" name="price_until" type="text" value="<? if(isset($_GET['price_until'])) echo $_GET['price_until']; ?>"/>
										</dd>
									</dl>
								</div>
							</div>

							<div class="unitESearch">
								<div class="unitPagination unitTPagination">
									<p>_i18n{found} <span><?php echo $count;?></span> _i18n{results for your request}</p>
									<ul>
										<?php for($i=0; $i<$pages; $i++){ ?>
											<li>
											<?php if(isset($_GET['page'])&&$_GET['page']==$i+1  || !isset($_GET['page'])&&$i==0) { ?>
												<span><?php echo $i+1; ?></span>
											<?php }else{ ?>
												<a href="/view-bargains.html?&page=<?php echo $i+1; ?>
													<?php echo isset($_GET['category_id']) ? '&category_id='.$_GET["category_id"] : NULL ; ?>
													<?php echo isset($_GET['subcategory_id']) ? '&subcategory_id='.$_GET["subcategory_id"] : NULL ; ?>
													<?php echo isset($_GET['country_id']) ? '&country_id='.$_GET["country_id"] : NULL ; ?>
													<?php echo isset($_GET['region_id']) ? '&region_id='.$_GET["region_id"] : NULL ; ?>
													<?php echo isset($_GET['price_from']) ? '&price_from='.$_GET["price_from"] : NULL ; ?>
													<?php echo isset($_GET['price_until']) ? '&price_until='.$_GET["price_until"] : NULL ; ?>
													<?php echo isset($_GET['order_name']) ? '&order_name='.$_GET["order_name"] : NULL ; ?>
													<?php echo isset($_GET['onpage']) ? '&onpage='.$_GET["onpage"] : NULL ; ?>
													<?php echo isset($_GET['search']) ? '&search='.$_GET["search"] : NULL ; ?>" title="1">
												<?php echo $i+1; ?>
												</a>
											<?php }?>
											</li>
										<?php } ?>
									</ul>
								</div>
								<div class="viewLSearch">
									<?php
									if(isset($orders)&&count($orders)>0&&$orders!=NULL){
									foreach($orders as $key => $order){?>
									<div class="unitLSearch">
										<div class="itemImg">
											<img src="<?php echo $order[UploadsService::PATH]; ?>" alt="<?php echo $order[OrdersService::ORDER_NAME]; ?>" />
										</div>
										<div class="itemText">
											<h3><a href="/view-bargain.html?id=<?php echo $order[OrdersService::HASH]; ?>" title="<?php echo $order[BargainsService::BARGAIN_NAME]; ?>"><?php echo $order[BargainsService::BARGAIN_NAME]; ?></a></h3>
											<div class="unitEqColumns">
												<dl>
													<dt>_i18n{category}:</dt>
													<dd><?php echo $order[CategoryService::CAT_NAME]; ?></dd>
												</dl>
												<dl>
													<dt>_i18n{subcategory}:</dt>
													<dd><?php echo $order[SubCategoryService::SUBCAT_NAME]; ?></dd>
												</dl>
											</div>
											<div class="unitEqColumns">
												<dl>
													<dt>_i18n{country}:</dt>
													<dd><?php echo $order[CountryService::COUNTRY_NAME]; ?></dd>
												</dl>
												<dl>
													<dt>_i18n{city}:</dt>
													<dd><?php echo $order[OrdersService::CITY]; ?></dd>
												</dl>
											</div>
										</div>
										<div class="itemPrice">
											<?php echo $order[BargainsService::BARGAIN_PRICE]; ?> &euro;
										</div>
									</div>
									<?php }
									} else { ?>
									_i18n{No Bargain like you want}
									<?php } ?>
								</div>
								<div class="unitPagination unitBPagination">
									<div class="itemPage">
										<label>_i18n{Items per page}:</label>
										<select name="onpage">
											<!-- 
											<option <?php echo isset($_GET['onpage'])&&$_GET['onpage']==1 ? "selected='selected'" : NULL ; ?>>1</option>
											<option <?php echo isset($_GET['onpage'])&&$_GET['onpage']==2 ? "selected='selected'" : NULL ; ?>>2</option>
											<option <?php echo isset($_GET['onpage'])&&$_GET['onpage']==3 ? "selected='selected'" : NULL ; ?>>3</option>
											 -->
											<option <?php echo isset($_GET['onpage'])&&$_GET['onpage']==5 ? "selected='selected'" : NULL ; ?>>5</option>
											<option <?php echo isset($_GET['onpage'])&&$_GET['onpage']==10 ? "selected='selected'" : NULL ; ?>>10</option>
											<option <?php echo isset($_GET['onpage'])&&$_GET['onpage']==50 ? "selected='selected'" : NULL ; ?>>50</option>
										</select>
									</div>
									<ul>
										<?php for($i=0; $i<$pages; $i++){ ?>
											<li>
											<?php if(isset($_GET['page'])&&$_GET['page']==$i+1  || !isset($_GET['page'])&&$i==0) { ?>
												<span><?php echo $i+1; ?></span>
											<?php }else{ ?>
												<a href="/view-bargains.html?&page=<?php echo $i+1; ?>
													<?php echo isset($_GET['category_id']) ? '&category_id='.$_GET["category_id"] : NULL ; ?>
													<?php echo isset($_GET['subcategory_id']) ? '&subcategory_id='.$_GET["subcategory_id"] : NULL ; ?>
													<?php echo isset($_GET['country_id']) ? '&country_id='.$_GET["country_id"] : NULL ; ?>
													<?php echo isset($_GET['region_id']) ? '&region_id='.$_GET["region_id"] : NULL ; ?>
													<?php echo isset($_GET['price_from']) ? '&price_from='.$_GET["price_from"] : NULL ; ?>
													<?php echo isset($_GET['price_until']) ? '&price_until='.$_GET["price_until"] : NULL ; ?>
													<?php echo isset($_GET['order_name']) ? '&order_name='.$_GET["order_name"] : NULL ; ?>
													<?php echo isset($_GET['onpage']) ? '&onpage='.$_GET["onpage"] : NULL ; ?>
													<?php echo isset($_GET['search']) ? '&search='.$_GET["search"] : NULL ; ?>" title="1">
												<?php echo $i+1; ?>
												</a>
											<?php }?>
											</li>
										<?php } ?>
									</ul>
								</div>
							</div>
						</form>
					</div>
				</div>
			</div>
			<div class="cB"><em class="cL"></em><em class="cR"></em></div>
		</div>
	</div>
</div>

<div class="wrapSSearch">
	<div class="viewBox viewBoxC">
		<div class="cT"><em class="cL"></em><em class="cR"></em></div>
		<div class="cL">
			<div class="cR">
				<div class="bodyBox">
					<h3>Sofort informiert sein über neue Angebote</h3>
					<div class="unitYellow">
						<form action="/view-bargains.html">
							<p><input type="text" class="inpTxt" title="Ihre E-Mail-Adresse" /></p>
							<p class="itemBtn">
								<button type="submit"><span><strong>Jetzt eintragen</strong></span></button>
							</p>
							<p class="itemSmall">Wir informieren Sie sofort über neu eintreffende Angebote welche mit Ihrer Selektion übereinstimmen.</p>
						</form>
					</div>
				</div>
			</div>
		</div>
		<div class="cB"><em class="cL"></em><em class="cR"></em></div>
	</div>
	
	<div class="viewBox viewBoxA">
		<div class="cT"><em class="cL"></em><em class="cR"></em></div>
		<div class="cL">
			<div class="cR">
				<div class="bodyBox">
					<div class="unitSearch">
						<form action="/view-orders.html">
							<p> 
								<label>Hauptkategorie?</label>
								<select name="category_id" class="gCategory">
	<?php					if (isset($categories) && $categories!=NULL){ 
									foreach($categories as $key=>$category){ ?>
									<option value="<?php echo $category[CategoryService::ID] ?>"><?php echo $category[CategoryService::CAT_NAME] ?></option>
	<?php 						} 
								} ?>
								</select>
							</p>
							<p>
								<label>Unterkategorie?</label>
								<select name="subcategory_id" class="gSubCategory">
	<?php					if (isset($subcategories_new) && $subcategories_new!=NULL){ 
									foreach($subcategories_new as $key=>$subcategory){ ?>
									<option value="<?php echo $subcategory[SubCategoryService::ID] ?>"><?php echo $subcategory[SubCategoryService::SUBCAT_NAME] ?></option>
	<?php 						}
								} ?> 
								</select>
							</p>
							<p class="itemBtn">
								<button type="submit"><span><strong>Angebot kostenlos holen!</strong></span></button>
							</p>
						</form>
					</div>
				</div>
			</div>
		</div>
		<div class="cB"><em class="cL"></em><em class="cR"></em></div>
	</div>
	
	<div class="viewBox viewBoxA">
		<div class="cT"><em class="cL"></em><em class="cR"></em></div>
		<div class="cL">
			<div class="cR">
				<div class="bodyBox">
					<h3>So finden Sie das beste Angebot!</h3>
					<div class="unitStep">
						<ol>
							<li>
								<span><img src="images/nbrFindR01.gif" alt="Ihren Auftrag kostenlos eintragen" /></span>
								<span>Ihren Auftrag kostenlos eintragen</span>
							</li>
							<li>
								<span><img src="images/nbrFindR02.gif" alt="Angebote vergleichen" /></span>
								<span>Angebote vergleichen</span>
							</li>
							<li>
								<span><img src="images/nbrFindR03.gif" alt="Auftrag vergeben" /></span>
								<span>Auftrag vergeben</span>
							</li>
						</ol>
					</div>
				</div>
			</div>
		</div>
		<div class="cB"><em class="cL"></em><em class="cR"></em></div>
	</div>
</div>